package org.visionlibrary.image.filters.clustering.proto.model;

import java.util.ArrayList;
import java.util.List;

public abstract class Cluster <T extends Clusterable<T>> {
    protected final List<T> samples;
    protected T centroid;

	public Cluster(final T centroid) {
		super();
		this.centroid = centroid;
		this.samples = new ArrayList<T>();
	}

	public boolean add(T element) {
		return samples.add(element);
	}
	
	public void clear() {
		samples.clear();
	}
	
	public List<T> getSamples() {
		return samples;
	}

	public T getCentroid() {
		return centroid;
	}
    
	@Override
	public String toString() {
		return "{centroid=" + centroid + "}{samples=" + samples.size() + "}";
	}
	
	public abstract void recalculate();
}
